@PACKAGE_INIT@

# 包含基础CMake功能
include(CMakeFindDependencyMacro)

# 手动创建导入目标
add_library(libunits::libunits STATIC IMPORTED)

# 设置目标属性
set_target_properties(libunits::libunits PROPERTIES
    IMPORTED_LOCATION "@PACKAGE_CMAKE_INSTALL_LIBDIR@/@CMAKE_STATIC_LIBRARY_PREFIX@units@CMAKE_STATIC_LIBRARY_SUFFIX@"
    INTERFACE_INCLUDE_DIRECTORIES "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@"
)

# 添加编译定义
target_compile_definitions(libunits::libunits INTERFACE
    $<$<NOT:$<BOOL:@BUILD_SHARED_LIBS@>>:UNITS_STATIC_DEFINE>
    $<$<NOT:$<BOOL:@BUILD_SHARED_LIBS@>>:LIBCONFIG_STATIC>
    $<$<NOT:$<BOOL:@BUILD_SHARED_LIBS@>>:LIBCONFIGXX_STATIC>
)

# 添加依赖项
find_library(UNITS_LIBRARY NAMES units PATHS "@PACKAGE_CMAKE_INSTALL_LIBDIR@" NO_DEFAULT_PATH)
find_library(LIBCONFIGPP_LIBRARY NAMES libconfig++ PATHS "@PACKAGE_CMAKE_INSTALL_LIBDIR@" NO_DEFAULT_PATH)

if(UNITS_LIBRARY AND LIBCONFIGPP_LIBRARY)
    set_target_properties(libunits::libunits PROPERTIES
        INTERFACE_LINK_LIBRARIES "${UNITS_LIBRARY};${LIBCONFIGPP_LIBRARY}"
    )
endif()

# 检查兼容性
check_required_components(libunits)